import request from '@/utils/request';

export async function queryWarehouse(params) {
  return request('/api/warWarehouses/selectByPage', {
    params,
  });
}
export async function queryWarehouseByProduct(params) {
  return request('/api/warWarehouses/selectWarehouseByProduct', {
    params,
  });
}

export async function removeWarehouse(params) {
  return request(`/api/warWarehouses/${params.warehouseId}`, {
    method: 'DELETE',
    data: { ...params},
  });
}
export async function addWarehouse(params) {
  return request('/api/warWarehouses', {
    method: 'POST',
    data: { ...params },
  });
}
export async function updateWarehouse(params) {
  return request('/api/warWarehouses', {
    method: 'PUT',
    data: { ...params },
  });
}
export async function enableWarehouse(params) {
  return request(`/api/warWarehouses/enable/${params.warehouseId}`, {
    method: 'POST',
    data: {  },
  });
}

export async function disableWarehouse(params) {
  return request(`/api/warWarehouses/disable/${params.warehouseId}`, {
    method: 'POST',
    data: {  },
  });
}

export async function queryWarehouseMaterial(params) {
  return request('/api/warWarehouseMaterials/selectByPage', {
    params,
  });
}
export async function materialIntoWarehouse(params) {
  return request('/api/warWarehouseMaterials/into', {
    method: 'POST',
    data: { ...params },
  });
}

export async function materialOutWarehouse(params) {
  return request('/api/warWarehouseMaterials/out', {
    method: 'POST',
    data: { ...params },
  });
}

export async function queryWarehouseMaterialHistory(params) {
  return request('/api/warWarehousesMaterialOiHistory/selectByPage', {
    params,
  });
}

export async function queryWarehouseProduct(params) {
  return request('/api/warWarehouseProducts/selectByPage', {
    params,
  });
}
export async function productIntoWarehouse(params) {
  return request('/api/warWarehouseProducts/into', {
    method: 'POST',
    data: { ...params },
  });
}

export async function productOutWarehouse(params) {
  return request('/api/warWarehouseProducts/out', {
    method: 'POST',
    data: { ...params },
  });
}

export async function productRepairWarehouse(params) {
  return request('/api/warWarehouseProducts/repair', {
    method: 'POST',
    data: { ...params },
  });
}

export async function productScrapWarehouse(params) {
  return request('/api/warWarehouseProducts/scrap', {
    method: 'POST',
    data: { ...params },
  });
}

export async function queryWarehouseProductHistory(params) {
  return request('/api/warWarehousesProductOiHistory/selectByPage', {
    params,
  });
}

export async function queryShipmentByPrdDay(params) {
  return request('/api/finShipmentByPrdDay/selectByPage', {
    params,
  });
}

/**
 * 模具库存分页查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryWarehouseMould(params) {
  return request('/api/warWarehouseMoulds/selectByPage', {
    params,
  });
}

/**
 * 模具入库
 * @param params
 * @returns {Promise<any>}
 */
export async function mouldIntoWarehouse(params) {
  return request('/api/warWarehouseMoulds', {
    method: 'POST',
    data: params,
  });
}

/**
 * 模具删除
 * @param params
 * @returns {Promise<any>}
 */
export async function mouldDeleteWarehouse(params) {
  return request(`/api/warWarehouseMoulds/${params.mouldId}`, {
    method: 'DELETE',
    data: { ...params },
  });
}

/**
 * 模具库存履历分页查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryWarehouseMouldHistory(params) {
  return request('/api/warWarehousesMouldOiHistory/selectByPage', {
    params,
  });
}
